﻿using SUNRPA.BROWSER.BRIDGE.domain;
using SUNRPA.CONTROLS.IMPL.domain.constant;
using System.Collections.Generic;

namespace SUNRPA.BROWSER.BRIDGE.util {
    public class BrowserRequestWrapper {
        public static Dictionary<string, string> methodMap = new Dictionary<string, string>(){ 
            { "CatchElement", DefaultContents.CATCH_ELE },
            { "OpenWebPage", DefaultContents.OPEN_WEBPAGE },
            { "ClickEle", DefaultContents.CLICK_ELE },
            { "InputTextToEle", DefaultContents.INPUT_TEXT },
            { "SelectDropDownValue", DefaultContents.SELECT_DDV },
            { "SelectDropDownByIndex", DefaultContents.SELECT_DDV_BYINDEX },
            { "DownloadByUrl", DefaultContents.DOWNLOAD_BYURL },
            { "SearchLatestDownloadItem", DefaultContents.SEARCH_LATEST_DOWNLOAD_ITEM },
            { "IsDownloadFinished", DefaultContents.ISDOWNLOAD_FINISHED },
            { "WaitEleShowUp", DefaultContents.WAIT_ELE_SHOWUP },
            { "WaitEleDisapper", DefaultContents.WAIT_ELE_DISAPPER },
            { "GetFocus", DefaultContents.GET_FOCUS },
            { "GetOpenedWebPage", DefaultContents.GET_OPENED_WEBPAGE },
        };
        public static BrowserRequest GetBrowserRequest(NamePipeRequest npr){ 
            BrowserRequest br = new BrowserRequest();
            methodMap.TryGetValue(npr.method, out string bm);
            br.method = bm;
            br.param = WrapParam(npr, bm);
            return br;
        }

        public static Dictionary<string, object> WrapParam(NamePipeRequest npr, string method){ 
            switch(method) {
                default : return npr.requestData;
            }
        }
    }
}
